﻿using HMEngine.HMCameras;
using HMEngine.HMComponents;
using Microsoft.Xna.Framework;

namespace HMEngine.HMEffects {
    public class HMShader : HMEffect {
        public HMShader(string asset) : base(asset) { }

        public override void SetParameters(IHMRenderable renderable) {
            Matrix world = 
                HMCameraManager.ActiveCamera.World * 
                Matrix.CreateScale(renderable.Scaling) * 
                Matrix.CreateFromQuaternion(renderable.Rotation) *
                Matrix.CreateTranslation(renderable.Position);

            if (null != Effect.Parameters["World"]) {
                Effect.Parameters["World"].SetValue(world);
            }

            if (null != Effect.Parameters["View"]) {
                Effect.Parameters["View"].SetValue(HMCameraManager.ActiveCamera.View);
            }

            if (null != Effect.Parameters["Projection"]) {
                Effect.Parameters["Projection"].SetValue(HMCameraManager.ActiveCamera.Projection);
            }
        }

        public override void UnloadContent() { }
    }
}